//
// Created by 60946 on 2022/10/14.
//

#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <unordered_map>

#ifndef ALGORITHM_22_1_SLN_L_1523_H
#define ALGORITHM_22_1_SLN_L_1523_H

using namespace std;

class Sln_L_1523 {
private:
    vector<pair<double, double>> JFs;
public:
    static bool cmp(const pair<double, double> &p1, const pair<double, double> &p2) {
        double x1, x2;
        if (fabs(p1.second) < 1e-6) {
            x1 = numeric_limits<double>::max();
        } else {
            x1 = p1.first / p1.second;
        }
        if (fabs(p2.second) < 1e-6) {
            x2 = numeric_limits<double>::max();
        } else {
            x2 = p2.first / p2.second;
        }
        return (x1 == x2) ? (p1.second > p2.second) : (x1 > x2);
    }

    Sln_L_1523() {
        double m;
        int n;
        while (scanf("%lf %d", &m, &n), fabs(m + 1) > 1e-6 && n != -1) {
            double j, f;
            for (int i = 0; i < n; i++) {
                scanf("%lf %lf", &j, &f);
                JFs.emplace_back(j, f);
            }
            sort(JFs.begin(), JFs.end(), cmp);
            double sum = 0;
            int i = 0;
            while (i < n && m > 0) {
                j = JFs[i].first;
                f = JFs[i].second;
                if (m >= f) {
                    m -= f;
                    sum += j;
                } else {
                    sum += m / f * j;
                    m = 0;
                }
                i++;
            }
            printf("%.3f\n", sum);
            JFs.clear();
        }

    }

};


#endif //ALGORITHM_22_1_SLN_L_1523_H
